package com.module.sys;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import flex.messaging.FlexContext;
import flex.messaging.FlexSession;

public class LoginSession {

	private static final String userid = "userid";
	private static final String username = "username";
	private static final String roleid = "roleid";
	private static final String rolename = "rolename";
	private static final String orgname = "orgname";
	private static final String orgid = "orgid";
	private static final String orgids = "orgids";
	private static final String orgtree = "orgtree";
	private static final String orgsac = "orgsac";
	private static final String menutree = "menutree";
	private static final String orgApp ="orgApp";
	private static final String pwd = "password";
	
	public void setSession(String useridt, String usernamet, String roleidt,
			String orgidt, String orgidst, List orgtreet, List orgsact,
			String rolenamet, String orgnamet, List menutreet,List orgApplist,String password) {
		FlexSession session = FlexContext.getFlexSession();
		session.setAttribute(userid, useridt);
		session.setAttribute(username, usernamet);
		session.setAttribute(orgid, orgidt);
		session.setAttribute(roleid, roleidt);
		session.setAttribute(orgids, orgidst);
		session.setAttribute(orgtree, orgtreet);
		session.setAttribute(orgsac, orgsact);
		session.setAttribute(rolename, rolenamet);
		session.setAttribute(pwd, password);
		session.setAttribute(orgname, orgnamet);
		session.setAttribute(menutree, menutreet);
		session.setAttribute(orgApp, orgApplist);
	}
	public  Map removeSession(){
		FlexSession session = FlexContext.getFlexSession();
		session.removeAttribute(userid);
		session.removeAttribute(username);
		session.removeAttribute(orgid);
		session.removeAttribute(roleid);
		session.removeAttribute(orgids);
		session.removeAttribute(orgtree);
		session.removeAttribute(orgsac);
		session.removeAttribute(rolename);
		session.removeAttribute(pwd);
		session.removeAttribute(orgname);
		session.removeAttribute(menutree);
		session.removeAttribute(orgApp);
		Map map = new HashMap();
		map.put("state", true);
		map.put("msg", "退出成功");
		return map;
	}

	public Map getSession() {
		FlexSession session = FlexContext.getFlexSession();
		Map map = new HashMap();
		map.put(orgid, session.getAttribute(orgid));
		map.put(orgids, session.getAttribute(orgids));
		map.put(orgsac, session.getAttribute(orgsac));
		map.put(orgtree, session.getAttribute(orgtree));
		map.put(roleid, session.getAttribute(roleid));
		map.put(userid, session.getAttribute(userid));
		map.put(username, session.getAttribute(username));
		map.put(rolename, session.getAttribute(rolename));
		map.put(orgname, session.getAttribute(orgname));
		map.put(menutree, session.getAttribute(menutree));
		map.put(orgApp, session.getAttribute(orgApp));
		map.put(pwd,session.getAttribute(pwd));
		return map;
	}

	public Map getSession1() {
		FlexSession session = FlexContext.getFlexSession();
		Map map = new HashMap();
		map.put(orgid, session.getAttribute(orgid));
		map.put(roleid, session.getAttribute(roleid));
		map.put(userid, session.getAttribute(userid));
		map.put(username, session.getAttribute(username));
		map.put(rolename, session.getAttribute(rolename));
		map.put(orgname, session.getAttribute(orgname));
		return map;
	}

	public static String getRolename() {
		return (String) FlexContext.getFlexSession().getAttribute(orgid);
	}

	public static String getPwd(){
		
		return (String) FlexContext.getFlexSession().getAttribute(pwd);
	}

	public static List getOrgApp() {
		return (List) FlexContext.getFlexSession().getAttribute(orgApp);
	}
	public static String getOrgname() {
		return (String) FlexContext.getFlexSession().getAttribute(orgname);
	}

	public static List getMenutree() {
		return (List) FlexContext.getFlexSession().getAttribute(menutree);
	}

	public static String getUserid() {
		return (String) FlexContext.getFlexSession().getAttribute(userid);
	}

	public static String getUsername() {
		return (String) FlexContext.getFlexSession().getAttribute(username);
	}

	public static String getRoleid() {
		return (String) FlexContext.getFlexSession().getAttribute(roleid);
	}


	public static String getOrgid() {
		return (String) FlexContext.getFlexSession().getAttribute(orgid);
	}

	public static String getOrgids() {
		return (String) FlexContext.getFlexSession().getAttribute(orgids);
	}
	public  static void setOrgids(String orgIds) {
		FlexContext.getFlexSession().setAttribute(orgids, orgIds);
	}

	public static List getOrgtree() {
		return (List) FlexContext.getFlexSession().getAttribute(orgtree);
	}

	public static List getOrgsac() {
		return (List) FlexContext.getFlexSession().getAttribute(orgsac);
	}


	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
